package com.File_io_.io_.reader_;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;

/**
 * @author 宋鑫宇
 * @version 1.0
 * 演示使用 InputStreamReader 转换流 解决中文乱码问题
 * 将字节流FileInputStream 转成字符流 InputStreamReader，指定编码 gbk/utf-8
 */
public class InputStreamReader_ {
    public static void main(String[] args) throws Exception {
        //指定gbk编码
        //把InputStreamReader 传入 BufferedReader
        BufferedReader br = new BufferedReader(new InputStreamReader(
                new FileInputStream("D:\\idea_WorkSpace\\myjava\\myjava\\src\\com\\File_io_\\date\\hello1.txt"), "gbk"));
        String s;
        while ((s = br.readLine()) != null) {
            System.out.println(s);
        }
        br.close();

    }
}
